package ru.mirent;

import org.junit.jupiter.api.Test;
import ru.mirent.JsonUtils;

import java.net.MalformedURLException;

public class JsonUtilsTest {

    /**
     * Пример разбора JSON.
     */
    @Test
    void formatTextTest() {
        String text = "{\n" +
                "  \"Roots\": [\n" +
                "    {\n" +
                "      \"name\": \"My Documents\",\n" +
                "      \"type\": \"Folder\",\n" +
                "      \"nestedObjects\": [\n" +
                "        {\n" +
                "          \"name\": \"Work\",\n" +
                "          \"type\": \"Folder\",\n" +
                "          \"nestedObjects\": [\n" +
                "             {\n" +
                "                \"name\": \"Monthly Report\",\n" +
                "                \"type\": \"File\",\n" +
                "                \"fileType\": \"{\\\"widget\\\":{\\\"debug\\\":\\\"on\\\",\\\"window\\\":{\\\"title\\\":\\\"Sample Konfabulator Widget\\\",\\\"name\\\":\\\"main_window\\\",\\\"width\\\":500,\\\"height\\\":500},\\\"image\\\":{\\\"src\\\":\\\"Images/Sun.png\\\",\\\"name\\\":\\\"sun1\\\",\\\"hOffset\\\":250,\\\"vOffset\\\":250,\\\"alignment\\\":\\\"center\\\"},\\\"text\\\":{\\\"data\\\":\\\"Click Here\\\",\\\"size\\\":36,\\\"style\\\":\\\"bold\\\",\\\"name\\\":\\\"text1\\\",\\\"hOffset\\\":250,\\\"vOffset\\\":100,\\\"alignment\\\":\\\"center\\\",\\\"onMouseUp\\\":\\\"sun1.opacity = (sun1.opacity / 100) * 90;\\\"}}}\",\n" +
                "                \"size\" :  1024\n" +
                "              }\n" +
                "          ]\n" +
                "        },\n" +
                "        {\n" +
                "          \"name\": \"YerlyReport\",\n" +
                "          \"type\": \"File\",\n" +
                "          \"fileType\": \"docx\",\n" +
                "          \"size\" :  2048\n" +
                "        }\n" +
                "      ]\n" +
                "    }\n" +
                "  ]\n" +
                "}";

        System.out.println(JsonUtils.prettiObject(text));
    }

    /**
     * Пример разбора объекта и вывод содержимого.
     */
    @Test
    void formatObjectTest() {
        System.out.println(JsonUtils.prettiObject(new MalformedURLException()));
    }
}
